package com.bigShen.pattern.rules.bDependenceInversion;

import com.bigShen.pattern.rules.bDependenceInversion.demo.Mother;
import com.bigShen.pattern.rules.bDependenceInversion.demo.NewsPaper;

/**
 * @Author eddy.shen
 * @Date 2020/2/25 21:49
 **/
public class DependenceInversionTest {

    public static void main(String[] args) {


        // v1
//        Mother mother = new Mother();
//        mother.readContent(new Story());

        // 这位妈妈 Mother 可以读故事 story ,
        // 但是如果 现在要读一份报纸， 就没有办法了


        // v2  readContent替换为接收接口IReader
//        Mother newMother = new Mother();
//        newMother.readContent(new NewsPaper());
//        newMother.readContent(new Story());

        // v3 构造器注入
//        Mother newMother = new Mother(new NewsPaper());
//        newMother.readContent();

        // v4 set方法依赖注入
        Mother newMother = new Mother();
        newMother.setReader(new NewsPaper());
        newMother.readContent();

    }

}
